copy (choose application with prompt "What application would you like to choose a menu item from?") to apl
copy text returned of (display dialog "What is the name of the menu in which the menu item is?" default answer "") to MenuName
copy text returned of (display dialog "What is the name of the item in the " & MenuName & " menu that you would like to choose?" default answer "") to ItemName
display dialog "The menu \"" & MenuName & "\" was not found in the application \"" & apl & "\"."
end if
if (founditem is false) and (foundmenu is true) then
display dialog "The menu item \"" & ItemName & "\" was not found in the menu \"" & MenuName & "\" in the application \"" & apl & "\"."
end if
end doMenuName
on QueryMenuList(apl)
try
tell apl
return («event Mænuqmn#»)
end tell
on error (errID)
copy word ((number of words in errID) - 2) of errID to errID
if errID = "126" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has no menu bar." to errText
else
copy "" to errText
end if
if errText is "" then
return errID
else
return {"error", errText}
end if
end try
end QueryMenuList
on QueryMenu(apl, MenuID)
try
tell apl
return («event Mænuqmn » given «class mnid»:MenuID)
end tell
on error (errID)
copy "" to errText
copy word ((number of words in errID) - 2) of errID to errID
if errID = "126" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has no menu bar." to errText
end if
if errID = "21000" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has no such menu (menu id " & MenuID & " was specified)." to errText
end if
if errID = "21004" then
copy "A Menu Events error occurred. The specified application (" & apl & ") does not support High Level Events." to errText
end if
if errText = "" then
return errID
else
return {"error", errText}
end if
end try
end QueryMenu
on DoMenuItem(apl, MenuID, MenuItemID)
try
tell apl
«event Mænusemi» given «class mnid»:MenuID, «class miid»:MenuItemID
end tell
return {""}
on error (errID)
copy word ((number of words in errID) - 2) of errID to errID
copy "" to errText
if errID = "126" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has no menu bar." to errText
end if
if errID = "1713" then
copy "A Menu Events error occurred. The specified application (" & apl & ¬
") is refusing to interact with other processes, or (if Menu Events extension is locked) with remote processes." to errText
end if
if errID = "21000" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has no such menu (menu id " & MenuID & " was specified)." to errText
end if
if errID = "21001" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has no such menu item (menu item id " & MenuItemID & " was specified)." to errText
end if
if errID = "21002" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has menu item id " & MenuItemID & " of menu id " & MenuID & " disabled." to errText
end if
if errID = "21003" then
copy "A Menu Events error occurred. The specified application (" & apl & ") has another Menu Event pending." to errText
end if
if errID = "21004" then
copy "A Menu Events error occurred. The specified application (" & apl & ") does not support High Level Events." to errText